#ifndef TIMER_CHANNEL_H_
#define TIMER_CHANNEL_H_

#include "./../channel/channel.h"

#include <cstdint>
#include <memory>
#include <functional>

class Loop;
class Description;
class TimerChannel : public ChannelProtocol,
                     public std::enable_shared_from_this<TimerChannel>
{
public:
    explicit TimerChannel(Loop * loop, std::shared_ptr<Description> description);
    ~TimerChannel() override = default;
    void    OnEvent(EventData & data) override;
    int     AddEvent(int event) override;
    int     ModEvent(int event) override;
    int     DelEvent() override;
    int     DescriptionData() override;
    int64_t Index() override;
    void    Index(int64_t index) override;
    void    Trigger(std::function<void(std::shared_ptr<ChannelProtocol>)> && function);
private:
    Loop *                       m_loop;
    std::shared_ptr<Description> m_description;
    int64_t                      m_index;
    std::function<void(std::shared_ptr<ChannelProtocol>)>        m_trigger_func;
};

#endif
